<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue-router的to属性</title>
</head>
<body>
<div id="app">
    <router-link :to="top">热点</router-link>
    <router-link :to="{name:'aaa'}">AAA</router-link>
    <router-link :to="{path:'/abouts'}">关于我们</router-link>
    <router-link :to="{path:'/discuss/10'}">讨论</router-link>
    <router-link :to="{name:'discuss',params: {id:10}}">讨论</router-link>
    <router-view></router-view>
</div>
<script src="../instances/vue.js"></script>
<script src="../instances/vue-router.js"></script>
<script>
    let Top = {
       template: `<div>热点</div>`
    }

    let AAA = {
        template: `<div>AAA</div>`
    }

    let Abouts = {
        template: `<div>关于我们</div>`
    }

    let Discuss = {
        template: `<div>讨论{{$route.params.id}}</div>`
    }

    let router = new VueRouter({
        routes: [{
          path: "/top",
          component: Top
        },{
          name: "aaa",
          path: "/aaa",
          component: AAA
        },{
            path: "/abouts",
            component: Abouts
        },{
            name: "discuss",
            path: "/discuss/:id",
            component: Discuss
        }]
    })

    let vm = new Vue({
      el: "#app",
      data: {
          top: "/top",
      },
      router
    })
</script>
</body>
</html>